﻿using Avalonia.Controls.Templates;

namespace KinonekoSoftware.Studio.Resources.Converters
{
    public sealed class CustomizationTemplateSelector : IDataTemplate
    {
        public Control Build(object param)
        {
            var item = (CustomizedInformation)param;
            var template = item.Type switch
            {
                CustomizedInformationType.Numeric => Numeric,
                CustomizedInformationType.Toggle  => Toggle,
                _                                 => Text,
            };
            return template.Build(param);
        }

        public bool Match(object data) => data is CustomizedInformation;

        public IDataTemplate Text    { get; set; }
        public IDataTemplate Numeric { get; set; }
        public IDataTemplate Toggle  { get; set; }
    }
}